# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        黄周云  
# Name:         test02
# Description:  例10.2
# Author:       ASUS
# Date:         2019/3/13
#-------------------------------------------------------------------------------


class Bird:
    def __init__(self):
        self.hungry = True
    def eat(self):
        if self.hungry:
            print("已经吃了虫子!")
            self.hungry = False
        else:
            print("已经吃过了，不饿了")
b = Bird()
b.eat()
b.eat()

class SongBird(Bird):
    def __init__(self):
        self.sound = '向天再借五百年'
    def sing(self):
        print(self.sound)

sb = SongBird()
sb.sing()
# sb.eat()                                  #报错，SongBird类重写了Bird类的构造方法，Bird类的构造方法中初始化的hungry变量也不存在了


class SongBird1(Bird):
    def __init__(self):
        self.sound = '向天再借五百年'
    def sing(self):
        print(self.sound)
    def eat(self,thing):
        print(thing)

sb = SongBird1()
sb.sing()
# sb.eat()                                   #报错，重写方法只看方法名，不看参数，SongBird1类中的eat方法覆盖了Bird类的同名方法